//q9.cpp
//This programs takes an array and the size and print the location of an odd and nonodd pair
//
//Binyamin 18 Jan 2018
//-------------------------------------------------------------------------------------------

#include<iostream>

using namespace std;

//find_change
//input: an array and size.
//output: the location of the pair
int find_change(int arr[], int size)
{
	int ret; // value to return.
	if(size<2) return -1;
	if((arr[0]%2 == 0) && (arr[1]%2 == 1)) return 0;
	ret = find_change(arr, size - size/2);
	if(ret>=0)
		return ret ;
	ret = find_change(arr + size/2, size);
	if(ret>=0)
		return ret + size/2;

}

//1. generate an array
//2. print the location of the change.
int main()
{
	int arr[] = {2, 4, 8, 7, 5, 4, 3}; // a test array
	cout << "The location of the change is " << find_change(arr, 7) << endl;
	return 0;
}
//output
//The location of the change is 2
